import 'package:flutter/cupertino.dart';
import 'package:xiongan_app_yy/common/user_singleton.dart';
import 'package:xiongan_app_yy/net/internet.dart';
import 'package:xiongan_app_yy/utils/toast_utils.dart';

class OutHandoverDetailsInfoProvider extends ChangeNotifier {
  bool _netStatus1 = false;
  Map<String,dynamic> _mapData = Map(); //数据
  get netStatus1 => _netStatus1;

  get mapData => _mapData;

  void getDetail(String id) async {
    Map<String, dynamic> sendObj = {
      'operaterUserId': DataSingleton().Data.id,
      'userId': DataSingleton().Data.id,
      'tenantId': DataSingleton().Data.tenantId,
      "warehouseid": DataSingleton().warehouseChoice.id,
      "id": id,
      "pageNo":-1
    };
    _netStatus1 = true;
    _mapData.clear();
    notifyListeners();
    // print(DataSingleton().warehouseChoice.id);
    Map<String, dynamic> res = await Internet()
        .get("WMS/MiWarehouseOutOrder/GetOutOrderHandoverWorkDetailInfo", params: sendObj);
    if (res['flag'] == "success") {
      _mapData = res['datas'];
    }else{
      TostUtil.showToast(res['msg']);
    }
    _netStatus1 = false;
    notifyListeners();
  }

  Future<dynamic> sendOrder(String id) async {
    Map<String, dynamic> sendObj = {
      "warehouseid": DataSingleton().warehouseChoice.id,
      "id": id
    };
    _netStatus1 = true;
    notifyListeners();
    Map<String, dynamic> res = await Internet().post(
        "WMS/MiWarehouseOutOrder/ConfirmOutOrderIsComplete",
        params: sendObj);
    if (res['flag'] == "success") {
      TostUtil.showToast("交接成功");
    } else {
      TostUtil.showToast(res['msg']);
    }
    _netStatus1 = false;
    notifyListeners();
    return res['datas'];
  }
}
